package br.ufg.inf.espweb.sgca.service.impl;

import br.ufg.inf.espweb.sgca.dao.GenericDao;
import br.ufg.inf.espweb.sgca.model.Entidade;
import br.ufg.inf.espweb.sgca.service.GenericService;
import java.util.List;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author diCastro
 */
@Transactional(propagation = Propagation.REQUIRED)
public abstract class GenericServiceImpl<T extends Entidade> implements GenericService<T>{
    
    protected abstract GenericDao<T> getDao();
    
    
    @Override
    public void salvar(T entity) {
        getDao().salvar(entity);
    }

    @Override
    public void atualizar(T entity) {
        getDao().atualizar(entity);
    }

    @Override
    public void remover(Long id) {
        getDao().remover(id);
    }

    @Override
    public T obterPorId(Long id) {
        return getDao().buscarPorId(id);
    }

    @Override
    public List<T> listar() {
        return getDao().listarTodos();
    }
}
